aboutsummaryrefslogtreecommitdiff
path: root/src/pages/board/[board].astro
blob: 69959aa7fa167db6cf398e52e8b82d7ff5ce240e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
import '../../styles/thread.css'
import '../../styles/blackbox.css'

import ThreadLayout from '../../layouts/ThreadLayout.astro';
import Thread from '../../components/Thread.astro'
import type Thread from '../../models/Thread';

import { api } from '../../lib/api.ts';
import { processThreadIn } from '../../lib/thread'

const { board } = Astro.params;
const data = await api('get', `board/${board}`);

if(data.status === 404) return Astro.redirect('/404');

const threads: Thread[] = await data.json();
---

<ThreadLayout>
  <h1 style="text-align:center">
    <a href=`/`>{board}</a>
  </h1>

  <div class="blackbox">
    <button style="left: 50%; position: relative; transform: translate(-50%, 0);" onclick=`window.location='/create/${board}'`>Create Thread</button>
  </div>

  {threads.map((thread) => (
    <Thread thread={thread} board={board} />
  ))}
</ThreadLayout>